﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MegauploadForum
{
    public class LinksFilter
    {
        private int m_start;
        private int m_length;
        private const string prefix = "http://www.megauploadforum.net/redirect.php?";
        public LinksFilter()
        {
            m_start = 12;
            m_length = 20;
        }
        public string[] Parse(string rawText)
        {
            IEnumerable<string> result;
            result = rawText.Split('\n');
            result = result.Select(link => link.Trim());
            result = result.Select(link => link.Trim(' ', '\r'));
            result = result.Where(link => !string.IsNullOrEmpty(link));
            result = result.Select(link => prefix + link.Substring(m_start, m_length));
            return result.ToArray();
            
        }
    }
}
